<template>
    <div>
        <!--面包协导航区域-->
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>权限列表</el-breadcrumb-item>
        </el-breadcrumb>
        <!--卡片视图-->
        <el-card>
            <el-table :data="rightslist" border stripe>
                <el-table-column type="index" label="#"></el-table-column>
                <el-table-column label="权限名称" prop="authName"></el-table-column>
                <el-table-column label="路径" prop="path"></el-table-column>
                <el-table-column label="权限等级" prop="level">
                    <template slot-scope="scope"> 
                        <el-tag v-if="scope.row.level==='0'">一级权限</el-tag>
                        <el-tag type="success" v-else-if="scope.row.level==='1'">二级权限</el-tag>
                        <el-tag type="warning" v-else>三级权限</el-tag>
                    </template>
                </el-table-column>
            </el-table>
            <!--分页区-->
            <!-- <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="queryInfo.pagenum"
                :page-sizes="[1, 2, 5, 10]"
                :page-size="queryInfo.pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
            </el-pagination>             -->
        </el-card>
    </div>
</template>

<script>
export default {    
    data(){
        return{
            //获取用户列表的参数对象
            queryInfo:{
                query: '',
                //当前页数
                pagenum:1,
                //当前每页显示多少条数据
                pagesize:2
            },
            total:0,
            //权限列表数组
            rightslist:[]
        }
    },
    created(){
        //获取权限列表
        this.getRightsList()
    },
    methods:{
        async getRightsList(){
           const {data:res} = await this.$http.get('rights/list',{params:this.queryInfo})
           if (res.meta.status !==200){return this.$message.error('获取权限列表失败')}
           this.rightslist = res.data
           this.total=res.data.total
           console.log(this.rightslist)
        },
        //监听 pagesize改变的事件
        handleSizeChange(newSize){
            //console.log(newSize)
            this.queryInfo.pagesize = newSize
            //需要重新加载数据
            this.getRightsList()
        },
        //监听 页码值 改变的事件
        handleCurrentChange(newPage){
            //console.log(newPage)
            this.queryInfo.pagenum = newPage
            this.getRightsList()
        },
    }
}
</script>

<style scoped>

</style>